package com.activitycode.adapter;

import java.util.ArrayList;
import java.util.List;

import android.R.integer;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.activitycode.activity.twitter.TwitterActivity;
import com.activitycode.datamodel.twitter.StarList;
import com.activitycode.datamodel.twitter.TwitterImage;
import com.activitycode.datamodel.twitter.TwitterMessage;
import com.activitycode.tools.OptionsTool;
import com.activitycode.tools.PictureUtils;
import com.activitycode.tools.TimeTools;
import com.activitycode.tools.UtilTools;
import com.activitycode.util.CommConstant;
import com.activitycode.util.LogUtil;
import com.activitycode.util.SharedPreferrenceManager;
import com.duostec.zhuyue.pets.R;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

public class TwitterListAdapter extends BaseAdapter {
	private static final double PAGER_RATE = 1.4;
	private static final double PAGER_RATE2 = 0.75;
	public List<TwitterMessage> baselist;
	private List<TwitterImage> imagelist;
	private List<StarList> starlist;
	private TwitterActivity ta = new TwitterActivity();
	private Context context;
	private DisplayImageOptions optionsHead, optionsLoad,optionsPetHead;
	ImageLoader imageLoader = ImageLoader.getInstance();
	private int p;
	private String userId;

	public TwitterListAdapter(List<TwitterMessage> baselist, Context context) {
		this.baselist = baselist;
		this.context = context;
		userId = SharedPreferrenceManager.getUserId(context);
		initOptions();
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return baselist.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return baselist.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@SuppressLint("ResourceAsColor")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.adapter_twitter_item, null);
			viewHolder.mMore = (TextView) convertView
					.findViewById(R.id.tv_more);
			viewHolder.nick_name = (TextView) convertView
					.findViewById(R.id.twitter_username_textview);
			viewHolder.pet_name = (TextView) convertView
					.findViewById(R.id.twitter_petnickname_textView);
			viewHolder.add_time = (TextView) convertView
					.findViewById(R.id.twitter_sendtime_textview);
			viewHolder.twitter_content = (TextView) convertView
					.findViewById(R.id.twitter_content_textview);
			viewHolder.keeper_image = (ImageView) convertView
					.findViewById(R.id.twitter_head_imageview);
			viewHolder.pet_image = (ImageView) convertView
					.findViewById(R.id.twitter_pethead_imageView);
			viewHolder.twitter_Praise_imageView = (ImageView) convertView
					.findViewById(R.id.twitter_Praise_imageView);
			viewHolder.twitter_show_imageView1 = (ImageView) convertView
					.findViewById(R.id.twitter_show_imageView1);
			viewHolder.twitter_show_imageView2 = (ImageView) convertView
					.findViewById(R.id.twitter_show_imageView2);
			viewHolder.twitter_show_imageView3 = (ImageView) convertView
					.findViewById(R.id.twitter_show_imageView3);
			viewHolder.twitter_show_imageView4 = (ImageView) convertView
					.findViewById(R.id.twitter_show_imageView4);
			viewHolder.twitter_show_imageView5 = (ImageView) convertView
					.findViewById(R.id.twitter_show_imageView5);
			viewHolder.twitter_show_imageView6 = (ImageView) convertView
					.findViewById(R.id.twitter_show_imageView6);
			viewHolder.twitter_show_imageView7 = (ImageView) convertView
					.findViewById(R.id.twitter_show_imageView7);
			viewHolder.twitter_show_imageView8 = (ImageView) convertView
					.findViewById(R.id.twitter_show_imageView8);
			viewHolder.twitter_show_imageView9 = (ImageView) convertView
					.findViewById(R.id.twitter_show_imageView9);
			viewHolder.twitter_show_onlyone_imageView1 = (ImageView) convertView
					.findViewById(R.id.twitter_show_onlyone_imageView1);
			viewHolder.container = (LinearLayout) convertView
					.findViewById(R.id.twitter_scrollView_Linear);
			viewHolder.twitter_prise_text = (TextView) convertView
					.findViewById(R.id.twitter_Praise_textView);
			viewHolder.twitter_assess_imageView = (ImageView) convertView
					.findViewById(R.id.twitter_assess_imageView);
			viewHolder.star_count = (TextView) convertView
					.findViewById(R.id.twitter_Praise_count);
			viewHolder.comment_count = (TextView) convertView
					.findViewById(R.id.twitter_comment_count);
			viewHolder.twitter_del_textView = (TextView) convertView
					.findViewById(R.id.twitter_del_textView);
			viewHolder.twitter_del = (LinearLayout) convertView
					.findViewById(R.id.twitter_del);
			viewHolder.twitter_pettype_textView = (TextView) convertView
					.findViewById(R.id.twitter_pettype_textView);
			viewHolder.twitter_attention_imageView = (ImageView) convertView
					.findViewById(R.id.twitter_attention_imageView);
			viewHolder.twitter_attention_textView = (TextView) convertView
					.findViewById(R.id.twitter_attention_textView);
			viewHolder.twitter_praise = (LinearLayout) convertView
					.findViewById(R.id.twitter_praise);
			viewHolder.twitter_assess = (LinearLayout) convertView
					.findViewById(R.id.twitter_assess);
			viewHolder.twitter_share = (LinearLayout) convertView
					.findViewById(R.id.twitter_share);
			viewHolder.twitter_attention = (LinearLayout) convertView
					.findViewById(R.id.twitter_attention);
			viewHolder.twitter_pertype_layout = (LinearLayout) convertView
					.findViewById(R.id.twitter_pertype_layout);

			convertView.setTag(viewHolder);
		} else {

			viewHolder = (ViewHolder) convertView.getTag();
		}
		initOptions();
		viewHolder.imagenamelist.add(viewHolder.twitter_show_imageView1);
		viewHolder.imagenamelist.add(viewHolder.twitter_show_imageView2);
		viewHolder.imagenamelist.add(viewHolder.twitter_show_imageView3);
		viewHolder.imagenamelist.add(viewHolder.twitter_show_imageView4);
		viewHolder.imagenamelist.add(viewHolder.twitter_show_imageView5);
		viewHolder.imagenamelist.add(viewHolder.twitter_show_imageView6);
		viewHolder.imagenamelist.add(viewHolder.twitter_show_imageView7);
		viewHolder.imagenamelist.add(viewHolder.twitter_show_imageView8);
		viewHolder.imagenamelist.add(viewHolder.twitter_show_imageView9);

		if ("1".equals(baselist.get(position).getIs_star())) {
			viewHolder.twitter_Praise_imageView
					.setImageResource(R.drawable.twitter_star1_down);
			viewHolder.twitter_prise_text.setText(R.string.praise_y);
			viewHolder.twitter_prise_text.setTextColor((context.getResources()
					.getColor(R.color.grey)));

		} else {
			viewHolder.twitter_Praise_imageView
					.setImageResource(R.drawable.twitter_star1);
			viewHolder.twitter_prise_text.setText(R.string.praise_no);
			viewHolder.twitter_prise_text.setTextColor(context.getResources()
					.getColor(R.color.title_text_color));
		}

		if ("1".equals(baselist.get(position).getIs_rel())) {
			viewHolder.twitter_attention_textView
					.setText(R.string.attention_yes);
			viewHolder.twitter_attention_textView.setTextColor(context
					.getResources().getColor(R.color.grey));
			viewHolder.twitter_attention_imageView
					.setImageResource(R.drawable.attention_yes);
		} else {
			viewHolder.twitter_attention_textView
					.setText(R.string.attention_no);
			viewHolder.twitter_attention_textView.setTextColor(context
					.getResources().getColor(R.color.title_text_color));
			viewHolder.twitter_attention_imageView
					.setImageResource(R.drawable.attention_no);
		}
		viewHolder.nick_name.setText(baselist.get(position).getNick_name());
		if (baselist.get(position).getPet_name() != null) {
			viewHolder.pet_name.setText(baselist.get(position).getPet_name());
		}
		if ("2".equals(baselist.get(position).getTwitter_type())) {
			viewHolder.twitter_pertype_layout.setBackground(context.getResources().getDrawable(R.drawable.shap_corner_bule));
		}else {
			viewHolder.twitter_pertype_layout.setBackground(context.getResources().getDrawable(R.drawable.shap_corner_red));
		}
		if (baselist.get(position).getStar_list() != null
				&& !(baselist.get(position).getStar_list().size() == 0)) {
			viewHolder.star_count.setText(""
					+ baselist.get(position).getStar_list().size());
		} else {
			viewHolder.star_count.setText("");
		}
		if (baselist.get(position).getComment_count() != null
				&& !baselist.get(position).getComment_count().equals("0")) {
			viewHolder.comment_count.setText(""
					+ baselist.get(position).getComment_count());
		} else {
			viewHolder.comment_count.setText("");
		}

		if (baselist.get(position).getCate_name() != null) {
			viewHolder.twitter_pettype_textView.setText(""
					+ baselist.get(position).getCate_name());
		}

		if (baselist.get(position).getTwitter_keeper().equals(userId)) {
			viewHolder.twitter_del.setVisibility(View.VISIBLE);
		} else {
			viewHolder.twitter_del.setVisibility(View.GONE);
		}

		String time1 = TimeTools.getTimeGap1(baselist.get(position)
				.getAdd_time().toString());

		viewHolder.add_time.setText(time1);

		// viewHolder.add_time.setText(TimeTools.getTimeGap(baselist.get(
		// position).getAdd_time()));
		viewHolder.twitter_content.setText((baselist.get(position)
				.getTwitter_content()));
		imageLoader.displayImage(CommConstant.SERVICE_HOST_IP_LAN_IMG
				+ baselist.get(position).getKeeper_image(),
				viewHolder.keeper_image, optionsHead);
		imageLoader.displayImage(CommConstant.SERVICE_HOST_IP_LAN_IMG
				+ baselist.get(position).getPet_image(), viewHolder.pet_image,
				optionsPetHead);
		final String twitter_id = baselist.get(position).getTwitter_id();
		final String pet_img = baselist.get(position).getPet_image();
		final String pet_name = baselist.get(position).getPet_name();
		final String pet_type = baselist.get(position).getCate_name();
		// Log.i("twitter_id+pet_img+pet_name",
		// "pet_name="+pet_name+"pet_img="+pet_img+"twitter_id="+twitter_id);
		final int p = position;

		Log.e("position", "" + position);

		viewHolder.mMore.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				doOnMoreClickListener(p);
			}
		});

		viewHolder.twitter_share.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				doOnShareClickListener(p);
			}
		});

		viewHolder.twitter_assess.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				doOnCommentClickListener(p, twitter_id, pet_img, pet_name,
						pet_type);

			}
		});
		viewHolder.twitter_praise.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// putStar(false,twitter_id);
				doOnListItemClickListener(p);

			}
		});
		viewHolder.twitter_attention.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				doOnAttentionClickListener(p, twitter_id);
			}
		});
		viewHolder.keeper_image.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub

				doOnHeadClickListener(p);
			}

		});
		viewHolder.twitter_del.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				doOnDelTwitterClickListener(p, twitter_id);
			}
		});
		imagelist = new ArrayList<TwitterImage>();
		imagelist = baselist.get(position).getImages();
		starlist = baselist.get(position).getStar_list();

		if (imagelist != null && imagelist.size() != 0) {
			if (imagelist.size() == 1) {
				int width = Integer.parseInt(imagelist.get(0).getImage_width());
				int height = Integer.parseInt(imagelist.get(0)
						.getImage_height());

				int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
				if (width > height) {
					viewHolder.twitter_show_onlyone_imageView1
							.getLayoutParams().height = (int) ((400) * PAGER_RATE2);

				} else if (width == height) {
					viewHolder.twitter_show_onlyone_imageView1
							.getLayoutParams().height = height * 300 / width;
				} else {
					viewHolder.twitter_show_onlyone_imageView1
							.getLayoutParams().height = (int) (800 / PAGER_RATE);

				}
				viewHolder.imagenamelist.get(0).setVisibility(View.GONE);
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.VISIBLE);
				viewHolder.twitter_show_onlyone_imageView1
						.setOnClickListener(new OnClickListener() {

							@Override
							public void onClick(View arg0) {
								// TODO Auto-generated method stub
								Log.e("p", "" + p);
								doOnOKListener(p, 0);
							}
						});
				imageLoader
						.displayImage(CommConstant.SERVICE_HOST_IP_LAN_IMG
								+ imagelist.get(0).getCut_path(),
								viewHolder.twitter_show_onlyone_imageView1,
								optionsLoad);

			} else {
				for (int i = 0; i < imagelist.size(); i++) {
					final int page = i;

					viewHolder.imagenamelist.get(i).setOnClickListener(
							new OnClickListener() {

								@Override
								public void onClick(View arg0) {
									// TODO Auto-generated method stub
									Log.e("page", "" + page);
									doOnOKListener(p, page);
								}
							});
					switch (page) {
					case 0:
						imageLoader
								.displayImage(
										CommConstant.SERVICE_HOST_IP_LAN_IMG
												+ imagelist.get(0)
														.getCut_path(),
										viewHolder.twitter_show_imageView1,
										optionsLoad);
						viewHolder.twitter_show_imageView1
								.setVisibility(View.VISIBLE);
						break;
					case 1:
						imageLoader
								.displayImage(
										CommConstant.SERVICE_HOST_IP_LAN_IMG
												+ imagelist.get(1)
														.getCut_path(),
										viewHolder.twitter_show_imageView2,
										optionsLoad);
						viewHolder.twitter_show_imageView2
								.setVisibility(View.VISIBLE);
						break;
					case 2:
						imageLoader
								.displayImage(
										CommConstant.SERVICE_HOST_IP_LAN_IMG
												+ imagelist.get(2)
														.getCut_path(),
										viewHolder.twitter_show_imageView3,
										optionsLoad);
						viewHolder.twitter_show_imageView3
								.setVisibility(View.VISIBLE);
						break;
					case 3:
						imageLoader
								.displayImage(
										CommConstant.SERVICE_HOST_IP_LAN_IMG
												+ imagelist.get(3)
														.getCut_path(),
										viewHolder.twitter_show_imageView4,
										optionsLoad);
						viewHolder.twitter_show_imageView4
								.setVisibility(View.VISIBLE);
						break;
					case 4:
						imageLoader
								.displayImage(
										CommConstant.SERVICE_HOST_IP_LAN_IMG
												+ imagelist.get(4)
														.getCut_path(),
										viewHolder.twitter_show_imageView5,
										optionsLoad);
						viewHolder.twitter_show_imageView5
								.setVisibility(View.VISIBLE);
						break;
					case 5:
						imageLoader
								.displayImage(
										CommConstant.SERVICE_HOST_IP_LAN_IMG
												+ imagelist.get(5)
														.getCut_path(),
										viewHolder.twitter_show_imageView6,
										optionsLoad);
						viewHolder.twitter_show_imageView6
								.setVisibility(View.VISIBLE);
						break;
					case 6:
						imageLoader
								.displayImage(
										CommConstant.SERVICE_HOST_IP_LAN_IMG
												+ imagelist.get(6)
														.getCut_path(),
										viewHolder.twitter_show_imageView7,
										optionsLoad);
						viewHolder.twitter_show_imageView7
								.setVisibility(View.VISIBLE);
						break;
					case 7:
						imageLoader
								.displayImage(
										CommConstant.SERVICE_HOST_IP_LAN_IMG
												+ imagelist.get(7)
														.getCut_path(),
										viewHolder.twitter_show_imageView8,
										optionsLoad);
						viewHolder.twitter_show_imageView8
								.setVisibility(View.VISIBLE);
						break;
					case 8:
						imageLoader
								.displayImage(
										CommConstant.SERVICE_HOST_IP_LAN_IMG
												+ imagelist.get(8)
														.getCut_path(),
										viewHolder.twitter_show_imageView9,
										optionsLoad);
						viewHolder.twitter_show_imageView9
								.setVisibility(View.VISIBLE);
						break;

					default:
						break;
					}

				}
			}
			switch (imagelist.size()) {

			case 0:
				for (int l = 0; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.GONE);
				break;
			case 1:
				for (int l = 1; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				break;
			case 2:
				for (int l = 2; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.GONE);
				break;
			case 3:
				for (int l = 3; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.GONE);
				break;
			case 4:
				for (int l = 4; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.GONE);
				break;
			case 5:
				for (int l = 5; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.GONE);
				break;
			case 6:
				for (int l = 6; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.GONE);
				break;
			case 7:
				for (int l = 7; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.GONE);
				break;
			case 8:
				for (int l = 8; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.GONE);
				break;

			default:
				for (int l = 0; l < 9; l++) {
					viewHolder.imagenamelist.get(l).setVisibility(View.GONE);
				}
				viewHolder.twitter_show_onlyone_imageView1
						.setVisibility(View.GONE);
				break;
			}

		} else {
			viewHolder.twitter_show_onlyone_imageView1.setVisibility(View.GONE);
			viewHolder.twitter_show_imageView1.setVisibility(View.GONE);
			viewHolder.twitter_show_imageView2.setVisibility(View.GONE);
			viewHolder.twitter_show_imageView3.setVisibility(View.GONE);
			viewHolder.twitter_show_imageView4.setVisibility(View.GONE);
			viewHolder.twitter_show_imageView5.setVisibility(View.GONE);
			viewHolder.twitter_show_imageView6.setVisibility(View.GONE);
			viewHolder.twitter_show_imageView7.setVisibility(View.GONE);
			viewHolder.twitter_show_imageView8.setVisibility(View.GONE);
			viewHolder.twitter_show_imageView9.setVisibility(View.GONE);

		}
		// getStarImage();

		try {

			viewHolder.container.removeAllViews();

			View zangView = null;

			if (starlist != null && starlist.size() != 0) {
				for (int i = 0; i < starlist.size(); i++) {
					zangView = LayoutInflater.from(context).inflate(
							R.layout.ui_twitter_starlist, null);
					ImageView headView = (ImageView) zangView
							.findViewById(R.id.twitter_scrollView_imageView1);
					imageLoader
							.displayImage(CommConstant.SERVICE_HOST_IP_LAN_IMG
									+ starlist.get(i).getHead_image(), headView);
					viewHolder.container.addView(zangView);

				}

			}
		} catch (Exception e) {
			e.printStackTrace();
		}

		long Count = PictureUtils.calculateLength(viewHolder.twitter_content
				.getText());
		LogUtil.e("" + Count);
		viewHolder.mMore.setVisibility(Count <= 52 ? View.GONE : View.VISIBLE);
		if (baselist.get(position).getIs_Closed()) {
			viewHolder.twitter_content.setMaxLines(3);
			viewHolder.mMore.setText(R.string.tv_more);

		} else {
			viewHolder.twitter_content.setMaxLines(30);
			viewHolder.mMore.setText(R.string.tv_close);

		}

		return convertView;
	}

	public final static class ViewHolder {
		boolean isCloose = true;
		TextView nick_name, pet_name, add_time, star_count, comment_count,
				twitter_prise_text, twitter_pettype_textView,
				twitter_attention_textView, twitter_del_textView;
		TextView twitter_content, mMore;
		ImageView keeper_image, pet_image, head_image,
				twitter_assess_imageView, twitter_show_onlyone_imageView1,
				twitter_Praise_imageView, twitter_attention_imageView,
				twitter_show_imageView1, twitter_show_imageView2,
				twitter_show_imageView3, twitter_show_imageView4,
				twitter_show_imageView5, twitter_show_imageView6,
				twitter_show_imageView7, twitter_show_imageView8,
				twitter_show_imageView9;
		List<ImageView> imagenamelist = new ArrayList<ImageView>();

		LinearLayout container, twitter_praise, twitter_assess, twitter_share,
				twitter_attention, twitter_del,twitter_pertype_layout;
	}

	private OnListItemClickListener onListItemClickListener;

	public interface OnListItemClickListener {
		public void onClick(int position);

	}

	public void setOnListItemClickListener(
			OnListItemClickListener onListItemClickListener) {
		this.onListItemClickListener = onListItemClickListener;

	}

	private void doOnListItemClickListener(int position) {
		if (onListItemClickListener != null) {
			this.onListItemClickListener.onClick(position);

		}
	}

	private OnMoreClickListener onMoreClickListener;

	public interface OnMoreClickListener {
		public void onClick(int position);

	}

	public void setOnMoreClickListener(OnMoreClickListener onMoreClickListener) {
		this.onMoreClickListener = onMoreClickListener;

	}

	private void doOnMoreClickListener(int position) {
		if (onMoreClickListener != null) {
			this.onMoreClickListener.onClick(position);

		}
	}

	private OnShareClickListener onShareClickListener;

	public interface OnShareClickListener {
		public void onClick(int position);

	}

	public void setOnShareClickListener(
			OnShareClickListener onShareClickListener) {
		this.onShareClickListener = onShareClickListener;

	}

	private void doOnShareClickListener(int position) {
		if (onShareClickListener != null) {
			this.onShareClickListener.onClick(position);

		}
	}

	private OnHeadClickListener onHeadClickListener;

	public interface OnHeadClickListener {
		public void onClick(int position);

	}

	public void setOnHeadClickListener(OnHeadClickListener onHeadClickListener) {
		this.onHeadClickListener = onHeadClickListener;

	}

	private void doOnHeadClickListener(int position) {
		if (onHeadClickListener != null) {
			this.onHeadClickListener.onClick(position);

		}
	}

	private OnOKListener onOKListener;

	public interface OnOKListener {
		public void onOK(int position, int page);

	}

	public void setOnOKListener(OnOKListener onOKListener) {
		this.onOKListener = onOKListener;

	}

	private void doOnOKListener(int position, int page) {
		if (onOKListener != null) {
			this.onOKListener.onOK(position, page);
		}
	}

	private OnCommentClickListener onCommentClickListener;

	public interface OnCommentClickListener {
		public void onClick(int position, String twitter_id, String pet_img,
				String pet_name, String pet_type);
	}

	public void setOnCommentClickListener(
			OnCommentClickListener onCommentClickListener) {
		this.onCommentClickListener = onCommentClickListener;
	}

	private void doOnCommentClickListener(int position, String twitter_id,
			String pet_img, String pet_name, String pet_type) {
		if (onCommentClickListener != null) {
			this.onCommentClickListener.onClick(position, twitter_id, pet_img,
					pet_name, pet_type);
		}
	}

	private OnAttentionClickListener onAttentionClickListener;

	public interface OnAttentionClickListener {
		public void onClick(int position, String twitter_id);
	}

	public void setOnAttentionClickListener(
			OnAttentionClickListener onAttentionClickListener) {
		this.onAttentionClickListener = onAttentionClickListener;
	}

	private void doOnAttentionClickListener(int position, String twitter_id) {
		if (onAttentionClickListener != null) {
			this.onAttentionClickListener.onClick(position, twitter_id);
		}
	}

	private OnDelTwitterClickListener onDelTwitterClickListener;

	public interface OnDelTwitterClickListener {
		public void onClick(int position, String twitter_id);
	}

	public void setOnDelTwitterClickListener(
			OnDelTwitterClickListener onDelTwitterClickListener) {
		this.onDelTwitterClickListener = onDelTwitterClickListener;
	}

	public void doOnDelTwitterClickListener(int position, String twitter_id) {
		if (onDelTwitterClickListener != null) {
			this.onDelTwitterClickListener.onClick(position, twitter_id);
		}

	}

	private void initOptions() {
		optionsLoad = OptionsTool.getLoadingOptions(context);
		optionsPetHead = OptionsTool.getHeadOptions1(context);
		optionsHead = OptionsTool.getHeadOptions(context);
	}

}
